package homework.Day0324.约瑟夫环;

import java.util.Queue;
import java.util.Scanner;

public class KillingGame {

    public static void main(String[] args) {
        System.out.println("请输入圈子总人数：");
        Scanner in = new Scanner(System.in);
        int num  = in.nextInt();
        System.out.println("第N个人将被杀死，请输入N：");
        int N = in.nextInt();

        CounterQueue<Integer> queue = new ArrayQueue<>(4);
        for (int i = 1; i <= num; i++) {
            queue.enqueue(i);
        }

        System.out.println("被杀死的人：");
        while (!queue.isEmpty()){
            for (int i = 1; i <= N ; i++) {
                queue.enqueue(queue.dequeue());
            }
                System.out.print(queue.dequeue() + "  ");
        }
    }
}
